<?php
	MYDCONN();
	$GLOBALS['MYD']->db_query("INSERT INTO ccenter_orders
			(Type, Time, sysUserCreate, sysUserAtribb,TimeOrder, Status)
			VALUES
			(1,'{$sysTime}',{$_SESSION[$SESSID]},0,'{$_POST['DatePay']}',2)");
	
	$Order = $GLOBALS['MYD']->db_array("SELECT Ref FROM ccenter_orders 
						WHERE sysUserCreate = {$_SESSION[$SESSID]} 
						ORDER BY Ref DESC
						LIMIT 0,1");
		
		$GLOBALS['MYD']->db_query("UPDATE ccenter_invoices
					SET Ord = {$Order[1]['Ref']}
					WHERE Ref IN ({$_POST['ref']})");
	if (isset($_POST['EditOrder'])) {
	$GLOBALS['MYD']->db_query("UPDATE ccenter_orders
					SET 
						Type = , 
						Time = , 
						TimeDone = , 
						sysUserCreate = , 
						sysUserAtribb = , 
						sysUserDone = ,
						TimeOrder = , 
						Status = 
					WHERE
						Ref = {$_POST['Order']}");
	}
	if (isset($_POST['RemOrder'])) {
	$GLOBALS['MYD']->db_query("UPDATE ccenter_orders
			SET Status = 5
			WHERE Ref = {$_POST['Order']}");
	}
	if (!isset($ERROR)) {
		echo '<div class="Confirm">Opera��o Executada.</div>';
		mn_field('button','ED','prtOrder','Imprimir','','','','" onclick="
			newprint(\''.$GLOBALS['URL'].'Aplications/Export_Print.mex?MOD=CCENTER0&ID=01&OB='.$Order[1]['Ref'].'\',\'_blank\');');
		} elseif (isset($Action)) {
		$Msg_ERROR = "Erro, n�o foi poss�vel conclu�r a opera��o.";
		}
?>